<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>标准对象</title>
	<!--<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>-->
</head>
<body>
<script>
	console.log("typeof 123:" + typeof 123);
	console.log("typeof NaN:" + typeof NaN);
	console.log("typeof 'str':" + typeof 'str');
	console.log("typeof true:" + typeof true);
	console.log("typeof undefined:" + typeof undefined);
	console.log("typeof Math.abs:" + typeof Math.abs );
	console.log("typeof null:" + typeof null);
	console.log("typeof []:" + typeof []);
	console.log("typeof {}:" + typeof {});

	//包装类对象
	//一般情况下不要使用包装对象。
	let n1 = new Number(123);
	let n2 = 123;
	//虽然new Number(123)显示出来的数值和123是一样的,但是 new Number(123) 已经是包装对象了
	console.log("typeof Number(123):" + typeof n1);
	console.log("new Number(123) === 123:" + n1 === n2 );

	let b1 = new Boolean(true);
	let b2 = true;
	console.log("typeof Boolean(true):" + typeof Boolean(true));
	console.log("new Boolean(true) === true:" + b1 === b2);

	let s1 = new String('Hello,World!');
	let s2 = 'Hello,World!';
	console.log("typeof new String('Hello,Wolrd!')" + typeof s1);
	console.log("new String('Hello,World!') === 'Hello,World!'" + s1 === s2);

	//如果不调用关键字 new 而 直接调用函数本身，那么会转换为对应的类型
	let n11 = Number('123');
	console.log("typeof n11:" + typeof n11);

	let b11 = Boolean('false');
	console.log("typeof b11:" + typeof b11);

	let b12 = Boolean('true');
	console.log("typeof b12:" + typeof b12);

	let s11 = String(123.45);
	console.log("typeof s11:" + typeof s11);

	//JavaScript 必须要遵守的规定
	/*
	1:不要使用 new Number(),new String(),new Boolean()创建对象
	2:用 parseInt(),parseFloat()转换任意类型到number
	3:用String() 转换任意对象到string类型,或者调用对象的toString方法
	4:通常不需要把任意类型转换为boolean再判断 可以世界使用 if (someVar) {...}来判断
	5:typeof 操作符可以判断出 string,number,boolean,function,object,undefined
	6:判断Array 直接用 Array.isArray()
	7:判断null 使用 someVar === null
	8:判断某个全局变量是否存在typeof window.myVar === 'undefined';
	9:判断内部变量是否存在 typeof myVar === 'undefined';
	 */
	//用number对象调用toString会报错
	let s21 = (123).toString();
	let s22 = 123..toString();
	console.log("s21 === s22:" + (s21 === s22));

</script>
</body>
</html>